package cn.dengta.webapp.live.entity;

import java.util.Date;

import cn.dengta.common.util.Common;
import cn.dengta.webapp.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 主播关注表
 *
 * @author lgy
 * @since 2023-01-31
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("im_live_follow_log")
public class LiveFollowLog extends BaseEntity {

	private static final long serialVersionUID = 1L;

	/** 用户ID */
	Long userId;
	/** 直播间ID */
	Long liveId;
	/** 主播ID */
	Long anchorUserId;
	/** 来源:（1=个人主页；2=广场；3=直播间） */
	Integer source;
	/** 添加操作时间 */
	Date addTime;

	public static LiveFollowLog of(Long userId, int source, Long liveId) {
		LiveFollowLog liveFollowLog = new LiveFollowLog();
		liveFollowLog.setLiveId(liveId);
		liveFollowLog.setSource(source);
		liveFollowLog.setAddTime(new Date());
		liveFollowLog.setUserId(userId);
		return liveFollowLog;
	}

	public String logKey() {
		return userId + Common.LINE_SEP + liveId;
	}

	public String source_() {
		if (source != null) {
			switch (source) {
				case 1:
					return "个人主页";
				case 2:
					return "广场";
				case 3:
					return "直播间";
			}
		}
		return null;
	}

	public static final String USER_ID = "user_id";
	public static final String LIVE_ID = "live_id";
	public static final String ANCHOR_USER_ID = "anchor_user_id";
	public static final String SOURCE = "source";
	public static final String ADD_TIME = "add_time";

}
